using System.Collections.Generic;
using System.Globalization;

namespace UI.Models.Catalog
{
    class ItemsPerProductViewModelFactory
    {
        internal ItemsPerProductViewModel CreateFrom(List<Core.Model.Item> items, Core.Model.Product product)
        {
            var viewModel =  new ItemsPerProductViewModel
                                 {
                                     ProductId = product.ProductId, 
                                     Name = product.Name,
                                     Description = product.Description
                                 };
            foreach (var item in items)
            {
                viewModel.Items.Add(new ItemListViewModel
                                        {
                                            ItemId = item.ItemId, 
                                            Name = item.Name, 
                                            Price = item.Price.ToString(CultureInfo.InvariantCulture)
                                        });
            }
            return viewModel;
        }
    }
}
